home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.programming,comp.sys.sgi.misc,comp.lang.c
- Subject: Re: C pointer question.
- Date: 3 Apr 1996 07:44:05 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4ju6c5INN2ee@keats.ugrad.cs.ubc.ca>
- References: <315BFDBB.773C@wight.hursley.ibm.com> <4jlhpl$i3c@hn.ocbbs.gen.nz> <31616BAF.5BAB@datalytics.com> <3162659B.6201@wight.hursley.ibm.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <3162659B.6201@wight.hursley.ibm.com>,
- Max Waterman <dwater@wight.hursley.ibm.com> wrote:
- >Ie what are the arguments for :
- >
- >char name1,
- > name2,
- > name3;
- >
- >over :
- >
- >char name1;
- >char name2;
- >char name3;
- >
- >?
- >
- >Aren't they identical?
- >
- >Any compiler boffs out there know about this?
-
- These are identical. But if you put too many declarators onto one declaration
- specifier string, an ANSI-compliant compiler may fail, because the standard
- says that a compiler is only required to process declarations that have at
- least 12 (AFAIR) declarators (if I interpreted the confusing paragraph
- correctly: I'm sure this article will be followed up with some clarifications
- and/or flames). This might be intended as a relief to parsers that build n-ary
- trees, where the number of children that a parse tree node can have is a fixed
- array contained in the node data structure:
-
- #define NUM_CHILD 15
-
- /*
- .
- .
- */
-
- struct parse_node {
- /* bunch of fields */
- struct parse_node child[NUM_CHILD];
- };
-
- Other than that, there is no difference. It's a matter of style. I'd tend to
- put _related_ variables onto one declaration specifier. For example, if I had
- an i and a j that were both indices into the same array, I would say:
-
- int i, j; /* these are indices into array foo[] */
-
- but if they were unrelated, I might put them in separate declarations:
-
- int i; /* this is an index into array foo[] */
- int n; /* number of bytes from fread() */
-
- --
-
-